Skip to content

ci: pass quote-capable outputs to the backport workflow shell via env vars - #13021

Merged
fregataa merged 3 commits into
mainfrom
fix/backport-workflow-quote-escape
Jul 22, 2026
Merged

ci: pass quote-capable outputs to the backport workflow shell via env vars#13021
fregataa merged 3 commits into
mainfrom
fix/backport-workflow-quote-escape

Conversation

@Yaminyam

Copy link
Copy Markdown
Member

Summary

The backport workflow's "Save result to file" step interpolated the milestones result JSON inline into a single-quoted bash string:

run: |
  echo '${{ steps.milestones.outputs.result }}' > /tmp/backport-results/....json

Any commit message containing an apostrophe terminates the quote early and the step dies with syntax error near unexpected token '(' — first triggered by #12985 (title contains aiohttp's), which lost its automatic 26.4 backport.

Why only now

The vulnerable payload only includes the commit message when a target branch was resolved at run time. Auditing all apostrophe-titled commits on main: #12898/#12638/#12278 had no milestone, and #11983's milestone was set 52 seconds after merge — so the payload stayed empty and the step passed. #12985 was the first apostrophe-titled PR with its milestone set before merge (per our new milestone discipline), which finally lit the latent bug. (Side finding: #11983 silently missed its 26.4 backport this way.)

History

Third instance of this defect class here: 8bac28817 (hotfix: shell var-expansion), then #7405 moved the commit message into an env: var for the jq arguments — but left this step and the author/labels interpolations behind.

Changes

Following the same env-var pattern (#7405 / GitHub's workflow-injection guidance):

  • Save result to file: result JSON via MILESTONES_RESULT env + printf '%s' (no shell parsing of the payload)
  • Get target branches: author / author-email / labels jq args via env vars
  • Cherry-pick: git config user.name/email via env vars

Verification

  • Reproduced the exact failing payload against both patterns: old → identical syntax error near unexpected token '('; new → file round-trips, JSON parses, apostrophe intact
  • YAML validates

After merge: re-dispatch the backport workflow for b166f88b3 (#12985) — and optionally f30e32437 (#11983, the silently-missed backport).

🤖 Generated with Claude Code

… vars

The "Save result to file" step interpolated the milestones result JSON
inline into a single-quoted shell string, so any commit message containing
an apostrophe broke the script (syntax error near unexpected token) and
silently dropped the backport -- first triggered by #12985, whose title
contains "aiohttp's". This is the third instance of the same defect class
in this workflow (8bac288, #7405), and #7405 fixed only the jq-argument
site while leaving this step and the author/labels interpolations behind.

Route every quote-capable value (result JSON, author, author email,
labels) through env vars, matching the pattern #7405 established for the
commit message, and write the result file with printf instead of echo.
Reproduced the exact failure payload against both patterns: the old one
fails identically, the new one round-trips the JSON intact.

Past apostrophe-titled PRs never hit this because their milestones were
absent (or set only after merge), so the vulnerable payload stayed empty.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 22, 2026 05:53
@Yaminyam
Yaminyam requested a review from a team as a code owner July 22, 2026 05:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the size:S 10~30 LoC label Jul 22, 2026
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Yaminyam Yaminyam added this to the 26.5 milestone Jul 22, 2026
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@fregataa
fregataa merged commit 9cabefd into main Jul 22, 2026
29 checks passed
@fregataa
fregataa deleted the fix/backport-workflow-quote-escape branch July 22, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10~30 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants